package com.cqan.box.controller;

import static com.cqan.common.ViewName.BOX_LIST;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.cqan.box.entity.Box;
import com.cqan.box.service.BoxService;
import com.cqan.controller.BaseController;
import com.cqan.orm.Page;
import com.cqan.orm.PropertyFilter;

@Controller
@RequestMapping("/box")
public class BoxController extends BaseController<Box> {

	@Resource
	private BoxService boxService;
	
	@RequestMapping(value="/list.htm")
	public ModelAndView list(Integer pageNo,HttpServletRequest request){
		ModelAndView mav = new ModelAndView(BOX_LIST);
		List<PropertyFilter> filters = PropertyFilter.buildFromHttpRequest(request);
		page.setPageNo(pageNo);
		page.setOrder(Page.DESC);
		page.setOrderBy("id");
		page = boxService.search(page, filters);
		mav.addObject("page", page);
		return mav;
	}
	

}
